package net.xiduth.game.player.dialogues.auto;

import net.xiduth.game.player.dialogues.Dialogue;


/**
 * 
 * @author Oracle
 * 
 * Handles PvM Rewards and info.
 *
 */
public class Page3PvM extends Dialogue {


	@Override
	public void start() {
		sendOptionsDialogue("PvM Rewards - Page 3", "Double spin ticket (150 pts.)", "Magic whistle (150 pts.)", "5x Recover special (125 pts.)" , "Overlord title (200 pts.)", "Next page...");
		stage = 4;
	}

	@Override
	public void run(int interfaceId, int option) {
		switch(stage) {
		case -1:
			sendOptionsDialogue("Select an Option", "How many points do I have?", "I would like to exchange my points.", "How do I get points?", "I would like to access my bank account.", "Never mind.");
			stage = 0;
			break;
		case 0:
			switch(option) {
			case OPTION_1:
				sendDialogue("You currently have " + player.getPvMPoints() + " points.");
				stage = -1;
				break;
			case OPTION_2:
				sendOptionsDialogue("PvM Rewards - Page 2", "50x Planks (25 pts.)", "50x Steel nails (25 pts.)", "50x Mahogany planks (30 pts.)" , "250x Stardust (200 pts.)", "Never mind.");
				stage = 4;
				break;
			case OPTION_3:
				sendDialogue("Each monster you kill will give you up to 5 PvM Points, the points can then be exchanged here.");
				stage = -1;
				break;
			case OPTION_4:
				player.getBank().openBank();
				player.getInterfaceManager().closeChatBoxInterface();
				break;
			case OPTION_5:
				player.getInterfaceManager().closeChatBoxInterface();
				break;
			}
			break;
		case 3:
			end();
			break;
		case 4:
			switch(option) {
		case OPTION_1: //24155 double spin ticket price: 150
				if (player.getPvMPoints() >= 150) {
				player.getBank().addItem(24155, 1, true);
				player.setPvMPoints(player.getPvMPoints()
						- 150);
				player.getInterfaceManager().closeChatBoxInterface();
				player.getInterfaceManager().sendChatBoxInterface(1189);
				player.getPackets().sendItemOnIComponent(1189, 1, 24155, 1);
				player.getPackets().sendIComponentText(1189, 4, "The item has been added to your bank.");
				stage = 3;
				}else{
				sendDialogue("You need 150 points to buy this item." );
				stage = 3;
				}
				break;
		case OPTION_2: //magic whistle 16 price: 150
			if (player.getPvMPoints() >= 150) {
			player.getBank().addItem(16, 1, true);
			player.setPvMPoints(player.getPvMPoints()
					- 150);
			player.getInterfaceManager().closeChatBoxInterface();
			player.getInterfaceManager().sendChatBoxInterface(1189);
			player.getPackets().sendItemOnIComponent(1189, 1, 16, 1);
			player.getPackets().sendIComponentText(1189, 4, "The item has been added to your bank.");
			stage = 3;
			}else{
			sendDialogue("You need 150 points to buy this item." );
			stage = 3;
			}
			break;
		case OPTION_3: //5x 15300 recover special price: 75
			if (player.getPvMPoints() >= 125) {
			player.getBank().addItem(15300, 5, true);
			player.setPvMPoints(player.getPvMPoints()
					- 125);
			player.getInterfaceManager().closeChatBoxInterface();
			player.getInterfaceManager().sendChatBoxInterface(1189);
			player.getPackets().sendItemOnIComponent(1189, 1, 15300, 1);
			player.getPackets().sendIComponentText(1189, 4, "The items have been added to your bank.");
			stage = 3;
			}else{
			sendDialogue("You need 30 points to buy this item." );
			stage = 3;
			}
			break;
		case OPTION_4: //title id: 14 overlord title price: 200
			if (player.getPvMPoints() >= 200) {
			player.getAppearence().setTitle(14);
			player.getInterfaceManager().closeChatBoxInterface();
			stage = 3;
			}else{
			sendDialogue("You need 200 points to buy this." );
			stage = 3;
			}
			break;
		case OPTION_5:
			player.getDialogueManager().startDialogue("Page4PvM");
			break;
		default:
			end();
			break;
		}}}

	@Override
	public void finish() {

	}

}
